package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Feedback;

/**
 * 
 * @author 
 *
 */
@DAO
public interface FeedbackDAO{
	
	@SQL("SELECT id,userId,link,phone,title,msg,stickAt,status,memo,pvNum,praiseNum,commentsNum,forwardNum,collectNum,deleteFlag,createUser,createAt,updateUser,updateAt FROM Feedback WHERE deleteFlag=1  #if(:t.msg!=''){and msg like '%##(:t.msg)%' } #if(:t.status!=''){ and status =:t.status } #if(:t.userId!='' && :t.userId!=null){ and userId =:t.userId } ORDER BY stickAt DESC,updateAt DESC LIMIT :t.start,:t.length ")
    List<Feedback> query(@SQLParam("t") Feedback feedback);
	
	@SQL("SELECT count(1) FROM Feedback WHERE deleteFlag=1  #if(:t.msg!=''){and msg like '%##(:t.msg)%' } #if(:t.status!=''){ and status =:t.status } #if(:t.userId!='' && :t.userId!=null){ and userId =:t.userId }")
    int querySize(@SQLParam("t") Feedback feedback);
    
    @SQL("select * from Feedback where id=:1")
    Feedback queryById(int id);
    
	@SQL("UPDATE Feedback SET status=:t.status,memo=:t.memo,updateUser=:t.updateUser,updateAT=now() WHERE id=:t.id")
    void update(@SQLParam("t") Feedback feedback);
    
    @SQL("UPDATE Feedback SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE Feedback SET stickAT=now(),updateAT=now() WHERE id=:1")
    void updateByStickTime(int id);
	
	@SQL("UPDATE Feedback SET stickAT=null,updateAT=now() WHERE id=:1")
    void updateByStickTimeIsNull(int id);
}